import 'package:flutter/material.dart';

import '../../app/res/app_color.dart';

/// * 作者: Tao
/// * 日期: 2025/11/6
/// * 时间: 14:17
/// * 描述: 商品垂直展示控件
class CommonProductVerticalWidget extends StatelessWidget {
  /// 商品图片链接
  final String imageUrl;

  /// 商品标题
  final String title;

  /// 商品描述
  final String content;

  /// 商品价格
  final int price;

  /// 是否显示更多详情内容,默认不显示
  final bool isShowContentMore;

  /// 构造函数
  /// * [imageUrl] 商品图片链接
  /// * [title] 商品标题
  /// * [content] 描述
  /// * [price] 价格
  const CommonProductVerticalWidget(
      {Key? key,
      required this.imageUrl,
      required this.title,
      required this.content,
      required this.price,
      this.isShowContentMore = false})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        color: AppColor.white,
        borderRadius: BorderRadius.all(Radius.circular(5.0)),
        boxShadow: [
          BoxShadow(
            color: AppColor.grey ?? Colors.grey,
            offset: Offset(0.0, 0.5),
            blurRadius: 5.0,
            spreadRadius: isShowContentMore ? 0.8 : 1.0,
          )
        ],
      ),
      child: Padding(
        padding: EdgeInsets.all(12.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Image.network(width: 150.0, height: 130.0, imageUrl, fit: BoxFit.contain),
            Spacer(),
            // 商品名称
            SizedBox(
              width: 150.0,
              child: Text(title,
                  style: TextStyle(fontSize: 13.0),
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis),
            ),
            SizedBox(height: 6.0),
            // 描述
            SizedBox(
              width: 150.0,
              child: Text(content,
                  style: TextStyle(fontSize: 10.0, color: AppColor.grey500),
                  maxLines: isShowContentMore ? 2 : 1,
                  overflow: TextOverflow.ellipsis),
            ),
            Text('￥$price', style: TextStyle(fontSize: 10.0, color: AppColor.red600)),
          ],
        ),
      ),
    );
  }
}
